# 项目原地址：https://juejin.cn/post/7362062562478784524?searchId=20240828141400153CB0B7D5018A5C37A9

import time
from celery import Celery

brokers = 'redis://127.0.0.1:6379/0'
backend = 'redis://127.0.0.1:6379/1'

app = Celery('tasks', broker=brokers, backend=backend)
app.config_from_object('celery_config')

@app.task 
def add(x, y):
    time.sleep(2)
    return x + y

# 指令
# celery -A tasks worker  --loglevel=info 启动worker
# celery -A tasks beat 使用beat处理任务